feat: add token metadata constants and upgrade stability test#194
Merged
Conversation
- Add TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS, CONTRACT_DESCRIPTION constants - Add VERSION and SCHEMA_VERSION_V3 constants - Update name(), symbol(), decimals(), contract_info() to use constants - Add test_token_metadata_preserved_after_upgrade regression test - Update test_token_metadata and test_contract_info tests to use constants Closes zintarh#58
Author
|
@zintarh please kindly review. Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Issue #58: Add test for name(), symbol(), decimals() return values stability across contract upgrades.
Changes Made
1. Added Token Metadata Constants (src/constants.rs)
TOKEN_NAME = "Stellar Wrap Registry"- BREAKING CHANGE if modifiedTOKEN_SYMBOL = "WRAP"- BREAKING CHANGE if modifiedTOKEN_DECIMALS = 0- Soulbound tokens are non-divisibleCONTRACT_DESCRIPTION = "Soulbound token registry for Stellar Wrap"VERSION = 1- Contract version to bump on WASM upgradesHASH_PREVIEW_BYTES = 8- Existing constant preservedEach token constant includes documentation warning that changing these values is a BREAKING CHANGE for indexers and downstream consumers that rely on stable token identifiers.
2. Updated Contract Functions (src/lib.rs)
name()now usesTOKEN_NAMEconstantsymbol()now usesTOKEN_SYMBOLconstantdecimals()now returnsTOKEN_DECIMALSconstantcontract_info()usesTOKEN_NAMEandCONTRACT_DESCRIPTIONconstantsTOKEN_NAMEandCONTRACT_DESCRIPTION3. Added Schema Version Constant (src/storage_types.rs)
SCHEMA_VERSION_V3 = 3for v2 → v3 migration support4. Added Regression Test (src/test.rs)
test_token_metadata()- Updated to use constantstest_token_metadata_preserved_after_upgrade()- New regression test verifying metadata stability across contract instances (simulates upgrade scenario)test_contract_info_returns_correct_fields()- Updated to use constantstest_version_returns_expected_value()- Updated to use VERSION constantAcceptance Criteria
Closes #58